package com.ssi.app.user.dao.impl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ssi.app.user.dao.UserDao;
import com.ssi.app.user.model.User;

public class IbatisUserDao extends SqlMapClientDaoSupport implements UserDao{

	public void delete(String userId) {
		
		getSqlMapClientTemplate().delete("User.deleteById", userId);
	}

	public User findById(String userId) {
		
		User user =(User)getSqlMapClientTemplate().queryForObject("User.findById", userId);
		return user;
	}

	public void save(User user) {
		
		getSqlMapClientTemplate().insert("User.insert", user);
	}

	@SuppressWarnings("unchecked")
	public List<User> searchAll() {
		
		List<User> users = (List<User>)getSqlMapClientTemplate().queryForList("User.searchAll");
		return users;
	}

	public void update(User user) {
		
		getSqlMapClientTemplate().update("User.update", user);
		
	}

}
